import java.io.FileInputStream;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;


public class ClientGuiUDP {
	public static void main(String[] args) throws IOException{
		DatagramSocket clientSK;
		DatagramPacket clientPK;
		byte[]buf=new byte[1024];
		clientSK=new DatagramSocket();
		FileInputStream fis=new FileInputStream("C:/Users/hao huynh/Desktop/onthigk_UDPT.rar");
		while(true)
		{
			if(fis.read()!=-1){
				clientPK=new DatagramPacket(buf, buf.length, InetAddress.getLocalHost(), 7777);
				clientSK.send(clientPK);
			}
			else{
				clientPK=new DatagramPacket("end".getBytes(), "end".getBytes().length, InetAddress.getLocalHost(), 7777);
				clientSK.send(clientPK);
				break;
			}
		}
		System.out.println("Cilent da gui file wa server....");
		clientSK.close();fis.close();
	}
}
